import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/14 11:02
 * @description 基本运算器，LeetCode同，但是还是不太熟悉
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<Character, Integer> map = new HashMap<>();
        map.put('-', 1);
        map.put('+', 1);
        map.put('*', 2);
        map.put('/', 2);
        while (sc.hasNextLine()) {
            String t = sc.nextLine();
            // 将所有的空格去掉
            t = t.replaceAll(" ", "");
            char[] cs = t.toCharArray();
            Stack<Integer> nums = new Stack<>();
            nums.push(0);
            Stack<Character> ops = new Stack<>();
            int n = t.length();
            for (int i = 0; i < n; i++) {
                char c = t.charAt(i);
                if (c == '(') {
                    ops.push(c);
                }else if ( c == ')') {
                    // 计算到最近一个左括号为止
                    while (!ops.isEmpty()) {
                        if (ops.peek() != '(') {
                            cal(nums, ops);
                        }else {
                            ops.pop();
                            break;
                        }
                    }
                }else {
                    if (Character.isDigit(c)) {
                        int u = 0, j = i;
                        // 将从 i 位置开始后面的连续数字整体取出，加入 nums
                        while (j < n && Character.isDigit(cs[j])) {
                            u = u * 10 + (cs[j++] - '0');
                        }
                        nums.push(u);
                        i = j - 1;
                    }else {

                        if (i > 0 && (cs[i - 1] == '(' || cs[i - 1] == '+' || cs[i - 1] == '-')) {
                            nums.push(0);
                        }
                        // 有一个新操作要入栈时，先把栈内可以算的都算了
                        // 只有满足「栈内运算符」比「当前运算符」优先级高/同等，才进行运算
                        while (!ops.isEmpty() && ops.peek() != '(') {
                            char prev = ops.peek();
                            if (map.get(prev) >= map.get(c)) {
                                cal(nums, ops);
                            } else {
                                break;
                            }
                        }
                        ops.push(c);
                    }
                }

            }
            // 将剩余的计算完
            while (!ops.isEmpty()) {
                cal(nums, ops);
            }
            System.out.println(nums.peek());
        }
    }
    public static void cal(Stack<Integer> nums, Stack<Character> ops) {
        if (nums.isEmpty() || nums.size() < 2) {
            return;
        }
        if (ops.isEmpty()) {
            return;
        }
        int b = nums.pop(), a = nums.pop();
        char op = ops.pop();
        int ans = 0;
        if (op == '+') {
            ans = a + b;
        } else if (op == '-') {
            ans = a - b;
        } else if (op == '*') {
            ans = a * b;
        } else if (op == '/') {
            ans = a / b;
        }
        nums.push(ans);
    }
}
